package com.neibu.hw5.demo03;

import com.neibu.hw4.Student;

import java.util.function.Consumer;

/**
 * @author bin
 * @date 2025 - 04 -02
 **/
public class MainTest {
    public static void main(String[] args) {
        Student stu01 = new Student("张三", 18);
        Student stu02 = new Student("李四", 19);
        Student stu03 = new Student("王五", 20);
        Student stu04 = new Student("赵六2", 21);
        Student[] students = {stu01, stu02, stu03, stu04};

        Consumer<Student[]> xingLi = (stuArr) -> {
            System.out.println("姓李的");
            for (Student student1 : stuArr) {
                String name = student1.getName();
                if (name.startsWith("李"))
                    System.out.println(student1);
            }
        };

        Consumer<Student[]> SanZi = (stuArr) -> {
            System.out.println("名字三个字的");
            for (Student student1 : stuArr) {
                String name = student1.getName();
                if(name.length() >= 3)
                    System.out.println(student1);
            }
        };

        Consumer<Student[] > chengNian = (stuArr) -> {
            System.out.println("成年的");
            for (Student student1 : stuArr) {
                int age = student1.getAge();
                if(age > 18)
                    System.out.println(student1);
            }
        };

        xingLi.andThen(SanZi.andThen(chengNian)).accept(students);
    }
}
